package com.situ.mall.service.impl;

import com.situ.mall.mapper.ShippingMapper;
import com.situ.mall.mapper.UserMapper;
import com.situ.mall.pojo.Shipping;
import com.situ.mall.pojo.User;
import com.situ.mall.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements IUserService {
    @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private ShippingMapper shippingMapper;

    @Override
    public User login(String username, String password) {
        return userMapper.login(username, password);
    }

    @Override
    public boolean inset(User user) {
        return userMapper.insertSelective(user) > 0;
    }

    @Override
    public List<Shipping> selectAddress(User user) {
        return shippingMapper.selectByUserId(user.getId());
    }

    @Override
    public boolean update(User user) {
        return userMapper.updateByPrimaryKeySelective(user) > 0;
    }
}
